<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
      >

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{messages.Testpaper}#{messages.Second}#{messages.Step}"/>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form" enctype="multipart/form-data">
                <h:panelGrid columns="1">
                    <h:panelGrid columns="2">
                        <h:inputText value="#{questionController.searchName}" immediate="true">
                            <f:ajax render="search"/>
                        </h:inputText>
                        <h:commandButton id="search" value="#{messages.Search}" action="#{questionController.search()}" immediate="true"
                                         disabled="#{null==questionController.searchName}"/>
                    </h:panelGrid>
                    <h:panelGrid id="mysubjectList">
                        <h:outputText escape="false" value="#{messages.Empty}" rendered="#{questionController.items.rowCount == 0}"/>
                        <h:panelGroup rendered="#{questionController.items.rowCount > 0}" >
                            <h:outputText value="#{questionController.pagination.pageFirstItem + 1}..#{questionController.pagination.pageLastItem + 1}/#{questionController.pagination.itemsCount}"/>&nbsp;
                            <h:commandLink action="#{questionController.pageOperation.previous}" value="#{messages.Previous} #{questionController.pagination.pageSize}" rendered="#{questionController.pagination.hasPreviousPage}"/>&nbsp;
                            <h:commandLink action="#{questionController.pageOperation.next}" value="#{messages.Next} #{questionController.pagination.pageSize}" rendered="#{questionController.pagination.hasNextPage}"/>&nbsp;
                            <h:dataTable value="#{questionController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" >
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="&nbsp;"/>
                                    </f:facet>
                                    <h:commandLink action="#{questionController.selectThisQuestion()}" value="#{messages.Edit}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{messages.QuestionTitle}"/>
                                    </f:facet>
                                    <h:outputText value="#{item.valueinfo}" escape="false"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{messages.Selection}" />
                                    </f:facet>
                                    <h:outputText escape="false"   value="#{item.getSecondContenItems()}" />
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{messages.Type}"/>
                                    </f:facet>
                                    <h:outputText value="#{questionControllerA.getTypeString(item.type)}"/>
                                </h:column>                                    
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{messages.Answer}"/>
                                    </f:facet>
                                    <h:outputText value="#{item.answer}"/>
                                </h:column>                                    
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{messages.Score}"/>
                                    </f:facet>
                                    <h:outputText value="#{item.score}"/>
                                </h:column>   
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{messages.Analysis}"/>
                                    </f:facet>
                                    <h:outputText escape="false"  value="#{item.analysis}"   p:id="myeditor" />
                                </h:column>   
                            </h:dataTable>
                        </h:panelGroup>
                    </h:panelGrid>
                    <h:commandLink action="#{testpaperController.createHandmakeTestpaper()}" value="#{messages.Finished}"/>
                </h:panelGrid>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

